package com.jse.io.nio.network.old.muti;

import java.net.InetAddress;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Client {
	public static void main(String[] args) throws Exception {
		Client client = new Client();
		client.testMutiClient();
		
		Thread.sleep(3000);
	}
	
	public void testMutiClient() throws Exception {
		Socket socket = new Socket(InetAddress.getLocalHost(), 88);
		ExecutorService executor = Executors.newFixedThreadPool(10);
		
		//为什么定时执行有问题 TODO
//		ScheduledExecutorService executor = Executors.newScheduledThreadPool(10);
		
//		for (int i = 0; i < 5; i++) {
			Runnable task = new ClientTask("ClientTask-" + Math.random(), socket);
			executor.execute(task);
			
//			executor.schedule(task, 1000, TimeUnit.SECONDS);
//		}
		executor.shutdown();
	}
}
